﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.TestTools.Coverage
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using UnityEngine.Bindings;

#nullable disable
namespace UnityEngine.TestTools
{
  /// <summary>
  ///   <para>Describes the interface for the code coverage data exposed by mono.</para>
  /// </summary>
  [NativeType("Runtime/Scripting/ScriptingCoverage.h")]
  [NativeClass("ScriptingCoverage")]
  public static class Coverage
  {
    /// <summary>
    ///   <para>Enables or disables code coverage. Note that Code Coverage can affect the performance.</para>
    /// </summary>
    /// <returns>
    ///   <para>Returns true if code coverage is enabled; otherwise, returns false.</para>
    /// </returns>
    public static extern bool enabled { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    [FreeFunction("ScriptingCoverageGetCoverageForMethodInfoObject", ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern CoveredSequencePoint[] GetSequencePointsFor_Internal(MethodBase method);

    [FreeFunction("ScriptingCoverageResetForMethodInfoObject", ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void ResetFor_Internal(MethodBase method);

    [FreeFunction("ScriptingCoverageGetStatsForMethodInfoObject", ThrowsException = true)]
    private static CoveredMethodStats GetStatsFor_Internal(MethodBase method)
    {
      CoveredMethodStats ret;
      Coverage.GetStatsFor_Internal_Injected(method, out ret);
      return ret;
    }

    /// <summary>
    ///   <para>Returns the coverage sequence points for the method you specify. See CoveredSequencePoint for more information about the coverage data this method returns.</para>
    /// </summary>
    /// <param name="method">The method to get the sequence points for.</param>
    /// <returns>
    ///   <para>Array of sequence points.</para>
    /// </returns>
    public static CoveredSequencePoint[] GetSequencePointsFor(MethodBase method)
    {
      return method != null ? Coverage.GetSequencePointsFor_Internal(method) : throw new ArgumentNullException(nameof (method));
    }

    /// <summary>
    ///   <para>Returns the coverage summary for the specified method. See CoveredMethodStats for more information about the coverage statistics returned by this method.</para>
    /// </summary>
    /// <param name="method">The method to get coverage statistics for.</param>
    /// <returns>
    ///   <para>Coverage summary.</para>
    /// </returns>
    public static CoveredMethodStats GetStatsFor(MethodBase method)
    {
      return method != null ? Coverage.GetStatsFor_Internal(method) : throw new ArgumentNullException(nameof (method));
    }

    /// <summary>
    ///   <para>Returns an array of coverage summaries for the specified array of methods.</para>
    /// </summary>
    /// <param name="methods">The array of methods.</param>
    /// <returns>
    ///   <para>Array of coverage summaries.</para>
    /// </returns>
    public static CoveredMethodStats[] GetStatsFor(MethodBase[] methods)
    {
      CoveredMethodStats[] statsFor = methods != null ? new CoveredMethodStats[methods.Length] : throw new ArgumentNullException(nameof (methods));
      for (int index = 0; index < methods.Length; ++index)
        statsFor[index] = Coverage.GetStatsFor(methods[index]);
      return statsFor;
    }

    /// <summary>
    ///   <para>Returns an array of coverage summaries for the specified type.</para>
    /// </summary>
    /// <param name="type">The type.</param>
    /// <returns>
    ///   <para>Array of coverage summaries.</para>
    /// </returns>
    public static CoveredMethodStats[] GetStatsFor(System.Type type)
    {
      return type != null ? Coverage.GetStatsFor(type.GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).OfType<MethodBase>().ToArray<MethodBase>()) : throw new ArgumentNullException(nameof (type));
    }

    /// <summary>
    ///   <para>Returns the coverage summary for all methods that have been called since either the Unity process was started or Coverage.ResetAll() has been called.</para>
    /// </summary>
    /// <returns>
    ///   <para>Array of coverage summaries.</para>
    /// </returns>
    [FreeFunction("ScriptingCoverageGetStatsForAllCoveredMethodsFromScripting", ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public static extern CoveredMethodStats[] GetStatsForAllCoveredMethods();

    /// <summary>
    ///   <para>Resets the coverage data for the specified method.</para>
    /// </summary>
    /// <param name="method">The method.</param>
    public static void ResetFor(MethodBase method)
    {
      if (method == null)
        throw new ArgumentNullException(nameof (method));
      Coverage.ResetFor_Internal(method);
    }

    /// <summary>
    ///   <para>Resets all coverage data.</para>
    /// </summary>
    [FreeFunction("ScriptingCoverageResetAllFromScripting", ThrowsException = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public static extern void ResetAll();

    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void GetStatsFor_Internal_Injected(
      MethodBase method,
      out CoveredMethodStats ret);
  }
}
